<template>
	<form class="memberItem" @submit="formSubmit" @reset="formReset">
		<view class="uni-form-item uni-column">
			<view class="title">成员名字</view>
			<view class="item">
				<input placeholder-style="font-size: 10px;" type="text" name="person_name" placeholder="如:张三, 李四" />
			</view>
		</view>
		<view class="uni-form-item uni-column">
			<view class="title">成员身份证号</view>
			<view class="item">
				<input placeholder-style="font-size: 10px;" type="idcard" name="person_identity" placeholder="成员身份证" />
			</view>
		</view>
		<view class="uni-form-item uni-column">
			<view class="title">是否开放成员注册（默认开放）</view>
			<view class="item">
				<radio-group name="person_sex">
					<label>
						<radio :checked="true" value="1" />男</label>
					<label>
						<radio value="2" />女</label>
					<label>
						<radio value="3" />保密</label>
				</radio-group>
			</view>
		</view>
		<view class="uni-form-item uni-column">
			<view class="title">成员编号</view>
			<view class="item">
				<input placeholder-style="font-size: 10px;" type="text" name="person_num" placeholder="学号、工号等" />
			</view>
		</view>
		<view class="uni-form-item uni-column">
			<view class="title">成员备注</view>
			<view class="item">
				<input placeholder-style="font-size: 10px;" type="text" name="person_remark" placeholder="如部门中的某分组不再建立团体，就写入备注" />
			</view>
		</view>
		<view class="uni-btn-v">
			<button type="default" form-type="reset">重置填写</button>
			<button :loading="false" form-type="submit">提交填写</button>
		</view>
	</form>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {
			formReset() {},
			formSubmit(e) {
				console.log(e.detail.value)
				uniCloud.callFunction({
					name: "ha_add_member",
					data: Object.assign(e.detail.value, {
						group_id: this.$route.query.group_id,
						order: 1
					}),
					success: ({
						result
					}) => {
						console.log(result)
						if (result.code === -1 || result.code === -2) {
							uni.showToast({
								icon:'none',
								title: result.msg
							});
						} else {
							uni.showToast({
								icon: "success",
								title: '添加成功！'
							});
							setTimeout(() => {
								uni.navigateBack({
									delta: 1
								});
							}, 1000)
						}
					}
				})
			}
		}
	}
</script>

<style>
	.uni-form-item {
		padding: 5rpx 0;
	}

	.memberItem__name {
		height: 50rpx;
		border: 1rpx solid #666;
	}

	.memberItem .item {
		padding: 5rpx 12rpx;
	}

	.memberItem .item input {
		padding-left: 24rpx;
		height: 80rpx;
		border: 1rpx solid rgba(102, 102, 102, 0.5);
	}

	.memberItem .text {
		font-size: 14px;
	}

	view {
		color: #666 !important;
	}
</style>
